from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import PermissionViewSet

# 创建一个默认路由器，并注册 PermissionViewSet
router = DefaultRouter()
router.register(r'permissions', PermissionViewSet)

urlpatterns = [
    # 注册视图集的路由（自动生成增删改查的URL）
    path('', include(router.urls)),

    # 自定义的临时权限分配与查询
    path('permissions/assign_temporary_permission/', PermissionViewSet.as_view({'post': 'assign_temporary_permission'}),
         name='assign_temporary_permission'),
    path('permissions/check_temp_permissions/', PermissionViewSet.as_view({'get': 'check_temp_permissions'}),
         name='check_temp_permissions'),

    # 自动更新权限的接口
    path('permissions/auto_update_permissions/', PermissionViewSet.as_view({'get': 'auto_update_permissions'}),
         name='auto_update_permissions'),
]
